package com.whstudio.util.mvc.data;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

import com.whstudio.util.string.StrUtil;

public abstract class BaseBean {

	protected Class<? extends BaseBean> myType = this.getClass();
	protected String className=getClassName();
	protected List<String> fields = getFieldList();

	protected String getClassName() {
		return getClassName(myType);
	}
	
	public String getClassName(Class<? extends Object> type){
		return type.getName().substring(
				type.getName().lastIndexOf(".")+1
				);
	}

	protected String lowFirstLetter(String str) {
		if(StrUtil.noe(str)){
			return "";
		}
		String firstLetter=str.substring(0, 1).toLowerCase();
		return firstLetter+str.substring(1);
	}

	private List<String> getFieldList() {
		Field[] fields=myType.getDeclaredFields();
		List<String> fieldList=new ArrayList<String>();
		for (int i = 0; i < fields.length; i++) {
			fieldList.add(fields[i].getName());
		}
		return fieldList;
	}

}
